﻿package mortal.game.view.rebate.shop.panel
{
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import extend.language.*;
    import fl.controls.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.rebate.item.*;
    import mortal.game.view.rebate.openServerSevenDay.data.*;
    import mortal.mvc.core.*;

    public class RebateShopPanel extends RebateTopPanel
    {
        protected var _buttom:RebateShopButtom;
        protected var _scrollPane:GScrollPane;
        protected var isResLoad:Boolean = false;

        public function RebateShopPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            LoaderHelp.addResCallBack(ResFileConst.rebateShop, this.onResLoadShop);
            return;
        }// end function

        private function onResLoadShop() : void
        {
            if (this.isDisposed)
            {
                return;
            }
            this.isResLoad = true;
            _bg = UIFactory.gImageBitmap(ImagesConst.RebatePanelBgShop, 0, 0, this);
            this.addChildAt(_bg, 0);
            this._dayTip.x = 274;
            this._dayTip.y = 147;
            _sec.x = 582;
            _sec.y = 143;
            _sec.text = "56";
            _min.x = 531;
            _min.y = 143;
            _min.text = "59";
            _day.x = 408;
            _day.y = 143;
            _day.text = "8";
            _hour.x = 461;
            _hour.y = 143;
            _hour.text = "23";
            this.addChildAt(_bg, 0);
            this._buttom = UIFactory.getUICompoment(RebateShopButtom);
            this._scrollPane = new GScrollPane();
            this._scrollPane.x = 0;
            this._scrollPane.y = 222;
            this._scrollPane.width = 690;
            this._scrollPane.height = 318;
            this._scrollPane.styleName = "chatScrollPane";
            this._scrollPane.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._scrollPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane.source = this._buttom;
            this.addChild(this._scrollPane);
            this._scrollPane.drawNow();
            this._scrollPane.update();
            Dispatcher.dispatchEvent(new DataEvent(EventName.RebateShopGetPanicBuyConfig));
            _activeTime.text = Language.getString(71923) + OpenServerSevenDayUtil.getTodayFullString();
            _actRule.text = "" + Language.getString(71924);
            _actRule.x = 280;
            _activeTime.x = 280;
            this.initData();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            if (this.isResLoad == false)
            {
                return;
            }
            this.isResLoad = false;
            _bg = null;
            _sec = null;
            _min = null;
            _day = null;
            _hour = null;
            this._scrollPane.dispose();
            this._scrollPane = null;
            Dispatcher.dispatchEvent(new DataEvent(EventName.RebateShopClose));
            return;
        }// end function

        public function updateItemNum(param1:Array) : void
        {
            if (this._buttom && param1 != null)
            {
                this._buttom.updateItemNum(param1);
                this.setTimeCountDown();
            }
            if (param1 && param1.length > 5)
            {
                this._scrollPane.verticalScrollPolicy = ScrollPolicy.AUTO;
            }
            else
            {
                this._scrollPane.verticalScrollPolicy = ScrollPolicy.OFF;
            }
            return;
        }// end function

        public function updatePlayerRecord(param1:Array) : void
        {
            if (this._buttom || param1 == null)
            {
                this._buttom.updatePlayerRecord(param1);
            }
            return;
        }// end function

        public function initData() : void
        {
            if (this._buttom)
            {
                this._buttom.initData();
            }
            return;
        }// end function

    }
}
